on my magellan now show up differently for virtuals and physicals.
Also, fix problem with magellan serial protocol on windows.
altitude altitude;
} position;
+/*
+ * Extended data if waypoint happens to represent a geocache. This is
+ * totally voluntary data...
+ */
+
+typedef enum {
+ gt_unknown = 0 ,
+ gt_traditional,
+ gt_multi,
+ gt_virtual,
+ gt_letterbox,
+ gt_event,
+ gt_suprise
+} geocache_type;
+
+typedef struct {
+ geocache_type type;
+ int diff; /* (multiplied by ten internally) */
+ int terr; /* (likewise) */
+} geocache_data ;
/*
* This is a waypoint, as stored in the GPSR. It tries to not
char *url_link_text;
const char *icon_descr;
time_t creation_time;
+ geocache_data gc_data;
} waypoint;
typedef void (*ff_init) (char const *);
* but that's not very nice for the folks near sea level.
*/
#define unknown_alt -99999999.0
+
static int in_time;
static int in_desc;
static int in_cdata;
+static int in_gs_type;
+static int in_gs_diff;
+static int in_gs_terr;
static char *cdatastr;
static XML_Parser psr;
tag_wpt(attr);
} if (strcmp(el, "time") == 0) {
in_time++;
+ } if (strcmp(el, "groundspeak:type") == 0) {
+ in_gs_type++;
+ } if (strcmp(el, "groundspeak:difficulty") == 0) {
+ in_gs_diff++;
+ } if (strcmp(el, "groundspeak:terrain") == 0) {
+ in_gs_terr++;
}
}
+struct
+gs_type_mapping{
+ geocache_type type;
+ const char *name;
+} gs_type_map[] = {
+ { gt_traditional, "Traditional cache" },
+ { gt_virtual, "Virtual cache" }
+};
+static
+geocache_type
+gs_mktype(char *t)
+{
+ int i;
+ int sz = sizeof(gs_type_map) / sizeof(gs_type_map[0]);
+
+ for (i = 0; i < sz; i++) {
+ if (0 == strcmp(t, gs_type_map[i].name)) {
+ return gs_type_map[i].type;
+ }
+ }
+ return gt_unknown;
+}
+
static void
gpx_end(void *data, const char *el)
{
+ float x;
if (in_cdata) {
if (in_name && in_wpt) {
wpt_tmp->shortname = xstrdup(cdatastr);
tm.tm_isdst = 1;
wpt_tmp->creation_time = mktime(&tm);
}
+ if (in_wpt && in_gs_type) {
+ wpt_tmp->gc_data.type = gs_mktype(cdatastr);
+ }
+ if (in_wpt && in_gs_diff) {
+ sscanf(cdatastr, "%f", &x);
+ wpt_tmp->gc_data.diff = x * 10;
+ }
+ if (in_wpt && in_gs_terr) {
+ sscanf(cdatastr, "%f", &x);
+ wpt_tmp->gc_data.terr = x * 10;
+ }
in_cdata--;
memset(cdatastr, 0, MY_CBUF);
}
in_ele--;
} else if (strcmp(el, "time") == 0) {
in_time--;
+ } if (strcmp(el, "groundspeak:type") == 0) {
+ in_gs_type--;
+ } if (strcmp(el, "groundspeak:difficulty") == 0) {
+ in_gs_diff--;
+ } if (strcmp(el, "groundspeak:terrain") == 0) {
+ in_gs_terr--;
}
}
* horrible state just I can concatenate buffers that it hands
* me as a cdata that are fragmented becuae they span a read. Grrr.
*/
-
if ((in_name && in_wpt) || (in_desc && in_wpt) || (in_ele) ||
+ (in_wpt && in_gs_type) ||
+ (in_wpt && in_gs_diff) ||
+ (in_wpt && in_gs_terr) ||
(in_time && (in_wpt || in_rte))) {
estr = cdatastr + strlen(cdatastr);
memcpy(estr, s, len);
-/*
+ /*
Communicate Thales/Magellan serial protocol.
Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
static int mag_error;
static int last_rx_csum;
static int found_done;
-static icon_mapping_t *icon_mapping;
static int got_version;
static int is_file = 0;
{ "an", "winery" },
{ "ao", "wreck" },
{ "ap", "zoo" },
+ { "ah", "Virtual cache"},
+ { "an", "Event"},
{ NULL, NULL }
};
{ mm_unknown, 0, NULL }
};
+static icon_mapping_t *icon_mapping = map330_icon_table;
/*
found_done = 1;
return;
}
-
mag_writeack(isum);
}
OPEN_EXISTING, 0, NULL);
if (comport == INVALID_HANDLE_VALUE) {
- fatal(MYNAME ": '%s'", portname);
+ char *buf;
+
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,GetLastError(),0,
+ (LPTSTR) &buf,0,NULL);
+ fatal(MYNAME ": '%s' cannot be opened. %s", portname, buf);
}
tio.DCBlength = sizeof(DCB);
GetCommState (comport, &tio);
ibuf[i]='a';
for(;i < size;i++) {
- if (ReadFile (comport, &ibuf[i], 1, &cnt, NULL) != TRUE)
+ if (ReadFile (comport, &ibuf[i], 1, &cnt, NULL) != TRUE)
break;
if (ibuf[i] == '\n') break;
}
ibuf[i] = 0;
return ibuf;
+
}
static void
fwrite(obuf, size, 1, magfile_out);
return;
}
-
WriteFile (comport, obuf, size, &len, NULL);
if (len != size) {
fatal(MYNAME ":. Wrote %d of %d bytes.", len, size);
mag_cleanse = m330_cleanse;
got_version = 1;
} else {
+ /*
+ * This is a serial device. The line has to be open for
+ * reading and writing, so we let rd_init do the dirty work.
+ */
+ fclose(magfile_out);
mag_rd_init(portname);
}
}
lat = (lat_deg * 100.0 + lat);
icon_token = mag_find_token_from_descr(waypointp->icon_descr);
+ switch (waypointp->gc_data.type) {
+ case gt_virtual:
+ icon_token = mag_find_token_from_descr("Virtual cache");
+ break;
+
+ }
owpt = global_opts.synthesize_shortnames ?
mkshort(waypointp->description) : waypointp->shortname,
odesc = waypointp->description ? waypointp->description : "";
{
if (!is_file) {
mag_readmsg();
+#if !__WIN32__
+ /*
+ * I have no idea why this is fatal under Windows.
+ */
mag_readmsg();
mag_readmsg();
mag_readmsg();
+#endif
}
/*
* Whitespace is actually legal, but since waypoint name length is